package com.rookie.shiro.module.constant;

public enum ErrorEnum {
    /*
     * 系统相关的错误提示信息
     * */
    E_400("400", "请求处理异常，请稍后再试"),
    E_500("500", "请求方式有误,请检查 GET/POST"),
    E_501("501", "请求路径不存在"),
    E_502("502", "权限不足"),
    E_503("503", "后台出现异常"),

    /*token相关*/
    E_30001("30001", "token已过期"),
    E_30002("30002", "token格式校验失败"),
    E_30003("30003", "token为空"),
    E_30004("30004", "token异常"),

    /*权限相关*/
    E_40001("40001", "权限不足"),
    E_40002("40002", "权限操作失败"),
    E_40003("40003", "当前权限不存在"),
    E_40004("40004", "当前角色不存在"),
    E_40005("40005", "角色操作失败"),
    E_40006("40006", "当前角色标识符已存在"),

    /*登录相关*/
    E_10001("10001", "验证码错误"),
    E_10002("10002", "该用户名已被注册"),
    E_10003("10003", "该邮箱已被绑定"),
    E_10004("10004", "该手机号已被注册"),
    E_10005("10005", "该账号已被注册"),
    E_10006("10006", "该用户未登录"),
    E_10007("10007", "该账号不存在"),
    E_10008("10008", "用户名或者密码错误"),
    E_10009("10009", "账号异常"),
    E_10010("10010", "验证码已过期"),

    /**
     * 用户相关
     */
    E_50001("50001","当前用户已被冻结");

    private String errorCode;

    private String errorMsg;

    ErrorEnum() {
    }

    ErrorEnum(String errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public static ErrorEnum getCode(String code){
        for(ErrorEnum errorEnum:ErrorEnum.values()){
            if(errorEnum.getErrorCode().equals(code)){
                return errorEnum;
            }
        }
        return null;
    }

}